﻿using UnityEngine;

public class BackgroundCtl : MonoBehaviour
{
    Material mat;
    Vector2 movement = Vector2.zero;

    public Vector2 speed = new Vector2 { x = 0, y = -0.5f };

    void Start()
    {
        mat = GetComponent<Renderer>().material;        
    }


    void Update()
    {
        movement += speed * Time.deltaTime;
        if (Mathf.Abs(movement.x) >= 1)
        {
            movement.x = 0;
        }
        if (Mathf.Abs(movement.y) >= 1)
        {
            movement.y = 0;
        }
        mat.mainTextureOffset = movement;
    }
}
